package com.igeekhome.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.igeekhome.mapper.SWarehouseMapper;
import com.igeekhome.pojo.SWarehouse;
import com.igeekhome.service.IWarehouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 立以宁
 */
@Service("warehouseService")
public class WarehouseServiceImpl implements IWarehouseService {

    @Autowired
    private SWarehouseMapper sWarehouseMapper;

    @Override
    public PageInfo<SWarehouse> selectByAll(Integer page, Integer limit) {
        List<SWarehouse> sWarehouses = sWarehouseMapper.selectByAll();
        PageHelper.startPage(page,limit);
        PageInfo<SWarehouse> pageInfo = new PageInfo(sWarehouses);

        return pageInfo;
    }

    @Override
    public SWarehouse selectByPrimaryKey(Integer id) {
        SWarehouse sWarehouse = sWarehouseMapper.selectByPrimaryKey(id);
        return sWarehouse;
    }

    @Override
    public void saveMethod(SWarehouse wh) {
        sWarehouseMapper.insert(wh);
    }

    @Override
    public void updateMethod(SWarehouse wh) {
        sWarehouseMapper.updateByPrimaryKey(wh);
}

    @Override
    public void deleteMethod(Integer id) {
        sWarehouseMapper.deleteByPrimaryKey(id);
    }
}
